package extras.salvation.api.methods;

import com.rsbuddy.script.methods.Npcs;
import com.rsbuddy.script.wrappers.Npc;

/**
 * @author Salvation
 * @version 1.0
 * @since 20-08-2011
 */
public final class ExtendedNpcs {

	/**
	 * @author Salvation
	 * @param name The (beginning) name of the Npc to be returned.
	 * @return The first matched Npc.
	 */
	public static Npc get(final String name) {
		final Npc[] npcs = Npcs.getLoaded();
		if (npcs == null) return null;
		for (final Npc n : npcs) {
			if (n.getName().toLowerCase().startsWith(name.toLowerCase())) {
				return n;
			}
		}
		return null;
	}
}